using System.Collections.Generic;
using JMClient.Models.Common;
using JMClient.Models.PhysicalComponents;
using Microsoft.EntityFrameworkCore;
namespace JMClient.Models.Data
{
    public class DeviceDbContext : DbContext
    {
        public DbSet<DeviceEntity> Devices { get; set; }
        public DbSet<SystemData.LogEntity> LogData { get; set; } // 表名为JMData

        // 配置 SQLite 数据库路径
        protected override void OnConfiguring(DbContextOptionsBuilder options)
            => options.UseSqlite("Data Source=JMData.db");
      
    }
} 
/*// ====== EF Core 数据库测试代码 ======
using (var context = new DeviceDbContext())
{
    context.Database.EnsureCreated(); // 自动建表

    // 新增一条数据
    var device = new DeviceEntity
    {
        Name = "运动控制器1",
        Type = "运动控制器",
        Description = "主控",
        Model = "MC-1000",
        Manufacturer = "某某公司"
    };
    context.Devices.Add(device);
    context.SaveChanges();

    // 查询所有数据
    var allDevices = context.Devices.ToList();
    foreach (var d in allDevices)
    {
        fileLog.Write($"数据库设备: {d.Id}: {d.Name} - {d.Type} - {d.Description}");
    }
}
// ====== END ======*/